package com.sky.controller.user;

import com.sky.Entity.SetMeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealDishVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("userSetmealController")
@RequestMapping("/user/setmeal")
@Api(tags = "套餐相关操作")
public class SetmealController {

    @Autowired
    private SetmealService service;

    @GetMapping("/list")
    @Cacheable(cacheNames = "setmealCache",key = "#categoryId")
    public Result<List<SetMeal>> querybyCategoryId(@RequestParam Long categoryId){
        List<SetMeal> list=service.queryByCategoryId(categoryId);
        return Result.success(list);
    }
    @GetMapping("/dish/{id}")
    public Result<List<SetmealDishVo>> queryDishsBySetmealId(@PathVariable Long id){
        List<SetmealDishVo> list=service.queryDishsBySetmealId(id);
        return Result.success(list);
    }
}
